﻿using INTEX.DataBase;
using INTEX.DataBase.Tools;
using ReflectionStudio.Core.Events;
using ReflectionStudio.Core.Helpers;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media;
using WPFExcelReport.Helpers;
namespace WPFExcelReport
{
    /// <summary>
    /// 1.获取需求数量日期
    /// 2.展开BOM，损耗规则
    /// 3.找到流程，创建流程
    /// 4.创建订单关系
    /// 5.动态产生下层需求
    /// 6.下层需求自动合并
    /// </summary>
    public partial class UIABPOS : ViewBase
    {

        public string flag = "N";
        public string PlanID = "YGR01";
        public bool IsOK = false;
        public SolidColorBrush RedBrush = new SolidColorBrush();

        public SolidColorBrush BlackBrush = new SolidColorBrush();

        public UIABPOS()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VABPOS();
            this.DataContext = MV; 
            RedBrush.Color = Colors.Red;
            BlackBrush.Color = Colors.Black;
        }

        public override void OnWorkflowIDChange(MessageEventArgs e)
        {
            IsBusy = true;
            base.OnWorkflowIDChange(e);
            MessageInfo msg = e.Info;
            string task = msg.MSGTYPE;
            switch (task)
            {
                case "LOADABP":
                    LOAD(msg.ORDER);
                    break;
                case "RESETPROD":
                    KEY = "";
                    AUF = "";
                    RULEKEY = "";
                    break;
            }

            IsBusy = false;
        }
        /// <summary>
        /// AB52用了KEY
        /// 规则用了 RULEKEY
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            dwAB = dwMaster;
            ERLKZ = false;
            if (dwMaster == null)
            {
                KEY = "";
                RULEKEY = "";
                AUF = "";
                ABAUF = "";
                PRART = "";
                KDPARTIE = "";
                TXTISIND = ""; 
            }
            else
            {
                KEY = TMV.ABPAUFKRS+ TMV.ABPAUFLFD+ TMV.ABPAUFPOS+ TMV.ABPPOSTYP + "V";
                PRART = TMV.ABPWAKZ + TMV.ABPART + TMV.ABPVAR + TMV.ABPFARBE + TMV.ABPBESCHICH + TMV.ABPDESS + TMV.ABPCOLORIT + TMV.ABPGROE; 
                if (TMV.ABPERLKZ == "J")
                    ERLKZ = true;
                KDPARTIE = TMV.ABPKDPARTIE;
                RULEKEY = TMV.ABPAUFKRS + TMV.ABPAUFLFD + TMV.ABPAUFPOS + TMV.ABPPOSTYP;
                TXTISIND = RULEKEY.PadRight(60);
                AUF = "P" + KEY;
                ABAUF = "V" + KEY; 
                
            }
            //此时规则和AB52应当进行了装载
        }

        public virtual void LOAD(string _order)
        {
            
            if (!_order.EndsWith(POSTYP))
                return;
            ORDERNUM = "";
            ORDERNUM = _order;
        }

        public override void LOADBYAUF()
        {
            TBMain.Clear();
            if (ORDERNUM.Length == 0)
                return;
            base.LOADBYAUF();
            PM["ORDERNUM"] = ORDERNUM;
            TMV.LOAD(PM);
            vwMaster.View.MoveCurrentToFirst();
        }
        public override void OnWHChg(string value)
        {
         
            if (MV == null)
                return;
            if (WH.Length < 4)
                return;
            TMV.PRLO = WH.Substring(0, 2);
            TMV.PRLB = WH.Substring(2, 2);
            TMV.PRLP = WH.Substring(4);
            if (!IsEdit)
                return;
            if (dwMaster == null)
                return;
            TMV.ABPZLO = WH.Substring(0, 2);
            TMV.ABPZLB = WH.Substring(2, 2);
            TMV.ABPBLO = WH.Substring(0, 2); 
            base.OnWHChg(value);
        }
        public override void OnPARTIEChg()
        {
            if (PARTIE.Length < 10)
                return;
            TBMain.Clear();
            dwData = TBMain.NewRow();
            dwData["ABPMANDANT"] = app.Mandant;
            dwData["ABPPOSTYP"] = POSTYP;
            dwData["ABPKDPARTIE"] = PARTIE.Substring(0, 10); 
            SResult =TMV.QABKDPARTIE(dwData);
            MergeData(SResult, true);
            base.OnPARTIEChg();
        }
    }
    public partial class UIABPOS
    {
        #region ==MATART===========
        public static readonly DependencyProperty MATARTProperty = DependencyProperty.Register("MATART",
        typeof(string), typeof(UIABPOS),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnMATARTChanged));
        public string MATART
        {
            get
            {
                return (string)GetValue(MATARTProperty);
            }
            set
            {
                SetValue(MATARTProperty, value);
            }
        }
        private static void OnMATARTChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.MATART = (string)e.NewValue;
            }
        }
        #endregion

        public VABPOS TMV
        {
            get
            {
                return (VABPOS)MV;
            }
        }

        #region ==IsNext===========
        public static readonly DependencyProperty IsNextProperty = DependencyProperty.Register("IsNext",
            typeof(bool), typeof(UIABPOS),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsNextChanged));
        public bool IsNext
        {
            get
            {
                return (bool)GetValue(IsNextProperty);
            }
            set
            {
                SetValue(IsNextProperty, value);
            }
        }
        private static void OnIsNextChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.IsNext = (bool)e.NewValue;
            }
        }
        #endregion
        
        #region ==FABP===========
        public static readonly DependencyProperty FABPProperty = DependencyProperty.Register("FABP",
            typeof(string), typeof(UIABPOS),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnFABPChanged));
        public string FABP
        {
            get
            {
                return (string)GetValue(FABPProperty);
            }
            set
            {
                SetValue(FABPProperty, value);
            }
        }
        private static void OnFABPChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.FABP = (string)e.NewValue;
            }
        }
        #endregion 

        #region ==IsShowOutPut===========
        public static readonly DependencyProperty IsShowOutPutProperty = DependencyProperty.Register("IsShowOutPut",
            typeof(bool), typeof(UIABPOS),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsShowOutPutChanged));
        public bool IsShowOutPut
        {
            get
            {
                return (bool)GetValue(IsShowOutPutProperty);
            }
            set
            {
                SetValue(IsShowOutPutProperty, value);
            }
        }
        private static void OnIsShowOutPutChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.IsShowOutPut = (bool)e.NewValue;
            }
        }
        #endregion  

        #region ==ARTK===========
        public static readonly DependencyProperty ARTKProperty = DependencyProperty.Register("ARTK",
            typeof(string), typeof(UIABPOS),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnARTKChanged));
        public string ARTK
        {
            get
            {
                return (string)GetValue(ARTKProperty);
            }
            set
            {
                SetValue(ARTKProperty, value);
            }
        }
        private static void OnARTKChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.ARTK = (string)e.NewValue;
            }
        }
        #endregion

        #region ==AUF===========
        public static readonly DependencyProperty AUFProperty = DependencyProperty.Register("AUF",
            typeof(string), typeof(UIABPOS),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnAUFChanged));
        public string AUF
        {
            get
            {
                return (string)GetValue(AUFProperty);
            }
            set
            {
                SetValue(AUFProperty, value);
                OnAUFChg(value);
            }
        }
        private static void OnAUFChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.AUF = (string)e.NewValue;
            }
        }
        public virtual void OnAUFChg(string auf)
        {
        }

        #endregion

        #region ==ABAUF===========
        public static readonly DependencyProperty ABAUFProperty = DependencyProperty.Register("ABAUF",
            typeof(string), typeof(UIABPOS),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnABAUFChanged));
        public string ABAUF
        {
            get
            {
                return (string)GetValue(ABAUFProperty);
            }
            set
            {
                SetValue(ABAUFProperty, value);
               
            }
        }
        private static void OnABAUFChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.ABAUF = (string)e.NewValue;
                src.OnABAUFChg((string)e.NewValue);
            }
        }
        public virtual void OnABAUFChg(string ABAUF)
        {
        }

        #endregion

        #region ==FAUF===========
        public static readonly DependencyProperty FAUFProperty = DependencyProperty.Register("FAUF",
            typeof(string), typeof(UIABPOS),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnFAUFChanged));
        public string FAUF
        {
            get
            {
                return (string)GetValue(FAUFProperty);
            }
            set
            {
                SetValue(FAUFProperty, value);
                OnFAUFChg(value);
            }
        }
        private static void OnFAUFChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.FAUF = (string)e.NewValue;
            }
        }
        public virtual void OnFAUFChg(string FAUF)
        {
        }

        #endregion

        #region ==IsGD===========
        public static readonly DependencyProperty IsGDProperty = DependencyProperty.Register("IsGD",
            typeof(bool), typeof(UIABPOS),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsGDChanged));
        public bool IsGD
        {
            get
            {
                return (bool)GetValue(IsGDProperty);
            }
            set
            {
                SetValue(IsGDProperty, value);
            }
        }
        private static void OnIsGDChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.IsGD = (bool)e.NewValue;
            }
        }
        #endregion

        #region ==dwVKP===========
        public static readonly DependencyProperty dwVKPProperty = DependencyProperty.Register("dwVKP",
            typeof(DataRow), typeof(UIABPOS),
            new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OndwVKPChanged));
        public DataRow dwVKP
        {
            get
            {
                return (DataRow)GetValue(dwVKPProperty);
            }
            set
            {
                SetValue(dwVKPProperty, value);
                if (MV == null) return;
                TMV.dwVKP = value;
            }
        }
        private static void OndwVKPChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.dwVKP = (DataRow)e.NewValue;
            }
        }
        #endregion

      

        #region ==dwRule===========
        public static readonly DependencyProperty dwRuleProperty = DependencyProperty.Register("dwRule",
          typeof(DataRow), typeof(UIABPOS),
          new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OdwRuleChanged));
        public DataRow dwRule
        {
            get
            {
                return (DataRow)GetValue(dwRuleProperty);

            }
            set
            {
                try
                {
                    SetValue(dwRuleProperty, value);
                    if (MV == null) return;
                    TMV.dwRule = value;
                }
                catch (Exception ex)
                {
                    Tracer.Error(ex.StackTrace, ex);
                }
            }
        }
        private static void OdwRuleChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                DataRow row = (DataRow)e.NewValue;
                src.dwRule = row;
            }
        }
        #endregion 
       
        #region ==PRART===========
        public static readonly DependencyProperty PRARTProperty = DependencyProperty.Register("PRART",
            typeof(string), typeof(UIABPOS),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnPRARTChanged));
        public string PRART
        {
            get
            {
                return (string)GetValue(PRARTProperty);
            }
            set
            {
                SetValue(PRARTProperty, value); 
               
            }
        }
        private static void OnPRARTChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.PRART = (string)e.NewValue;
                src.OnPRARTChg((string)e.NewValue);
            }
        }
        public virtual void OnPRARTChg(string value)
        { }
        #endregion

        #region ==KDPARTIE===========
        public static readonly DependencyProperty KDPARTIEProperty = DependencyProperty.Register("KDPARTIE",
            typeof(string), typeof(UIABPOS),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnKDPARTIEChanged));
        public string KDPARTIE
        {
            get
            {
                return (string)GetValue(KDPARTIEProperty);
            }
            set
            {
                SetValue(KDPARTIEProperty, value);
                OnKDPARTIEChg(value);
            }
        }
        private static void OnKDPARTIEChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.KDPARTIE = (string)e.NewValue;
            }
        }
        public virtual void OnKDPARTIEChg(string value)
        { }
        #endregion 
        

        #region ==JW===========
        public static readonly DependencyProperty JWProperty = DependencyProperty.Register("JW",
            typeof(string), typeof(UIABPOS),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnJWChanged));
        public string JW
        {
            get
            {
                return (string)GetValue(JWProperty);
            }
            set
            {
                SetValue(JWProperty, value);
                OnJWChg(value);
            }
        }
        private static void OnJWChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.JW = (string)e.NewValue;
            }
        }
        public virtual void OnJWChg(string value)
        { }
        #endregion

        #region ==POSTYP===========
        public static readonly DependencyProperty POSTYPProperty = DependencyProperty.Register("POSTYP",
            typeof(string), typeof(UIABPOS),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnPOSTYPChanged));
        public string POSTYP
        {
            get
            {
                return (string)GetValue(POSTYPProperty);
            }
            set
            {
                SetValue(POSTYPProperty, value);
                if (MV == null) return;
                TMV.POSTYP = value;
            }
        }
        private static void OnPOSTYPChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.POSTYP = (string)e.NewValue;
            }
        }
        #endregion

        #region ==RULEKEY===========
        public static readonly DependencyProperty RULEKEYProperty = DependencyProperty.Register("RULEKEY",
            typeof(string), typeof(UIABPOS),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnRULEKEYChanged));
        public string RULEKEY
        {
            get
            {
                return (string)GetValue(RULEKEYProperty);
            }
            set
            {
                SetValue(RULEKEYProperty, value);
                if (MV == null) return;
                TMV.RULEKEY = value;
            }
        }
        private static void OnRULEKEYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.RULEKEY = (string)e.NewValue;
            }
        }
        #endregion

        #region ==ABTP===========
        public static readonly DependencyProperty ABTPProperty = DependencyProperty.Register("ABTP",
            typeof(string), typeof(UIABPOS),
            new FrameworkPropertyMetadata("                                                  ", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnABTPChanged));
        public string ABTP
        {
            get
            {
                return (string)GetValue(ABTPProperty);
            }
            set
            {
                SetValue(ABTPProperty, value); 
            }
        }
        private static void OnABTPChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.ABTP = (string)e.NewValue;
                src.OnABTPChg((string)e.NewValue);
            }
        }
        public virtual void OnABTPChg(string value)
        {

        }
        #endregion
        
        #region ==dwAB===========
        public static readonly DependencyProperty dwABProperty = DependencyProperty.Register("dwAB",
            typeof(DataRow), typeof(UIABPOS),
            new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OndwABChanged));
        public DataRow dwAB
        {
            get
            {
                return (DataRow)GetValue(dwABProperty);
            }
            set
            {
                SetValue(dwABProperty, value);
                if (MV == null)
                    return;
                TMV.dwAB = value; 
            }
        }
        private static void OndwABChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.dwAB = (DataRow)e.NewValue;
            }
        }
        #endregion

        #region ==dwGS===========
        public static readonly DependencyProperty dwGSProperty = DependencyProperty.Register("dwGS",
            typeof(DataRow), typeof(UIABPOS),
            new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OndwGSChanged));
        public DataRow dwGS
        {
            get
            {
                return (DataRow)GetValue(dwGSProperty);
            }
            set
            {
                SetValue(dwGSProperty, value);
            }
        }
        private static void OndwGSChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.dwGS = (DataRow)e.NewValue;
            }
        }
        #endregion

        #region ==ERLKZ===========
        public static readonly DependencyProperty ERLKZProperty = DependencyProperty.Register("ERLKZ",
            typeof(bool), typeof(UIABPOS),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnERLKZChanged));
        public bool ERLKZ
        {
            get
            {
                return (bool)GetValue(ERLKZProperty);
            }
            set
            {
                SetValue(ERLKZProperty, value);
            }
        }
        private static void OnERLKZChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.ERLKZ = (bool)e.NewValue;
            }
        }
        #endregion

        #region ==IsShowSY===========
        public static readonly DependencyProperty IsShowSYProperty = DependencyProperty.Register("IsShowSY",
        typeof(bool), typeof(UIABPOS),
        new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsShowSYChanged));
        public bool IsShowSY
        {
            get
            {
                return (bool)GetValue(IsShowSYProperty);
            }
            set
            {
                SetValue(IsShowSYProperty, value);
                IsShowMaster = !value;
            }
        }
        private static void OnIsShowSYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.IsShowSY = (bool)e.NewValue;
            }
        }
        #endregion

        #region ==IsShowVK===========
        public static readonly DependencyProperty IsShowVKProperty = DependencyProperty.Register("IsShowVK",
        typeof(bool), typeof(UIABPOS),
        new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsShowVKChanged));
        public bool IsShowVK
        {
            get
            {
                return (bool)GetValue(IsShowVKProperty);
            }
            set
            {
                SetValue(IsShowVKProperty, value);
                IsShowMaster = !value;
            }
        }
        private static void OnIsShowVKChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.IsShowVK = (bool)e.NewValue;
            }
        }
        #endregion 

        #region ==IsShowCP===========
        public static readonly DependencyProperty IsShowCPProperty = DependencyProperty.Register("IsShowCP",
        typeof(bool), typeof(UIABPOS),
        new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsShowCPChanged));
        public bool IsShowCP
        {
            get
            {
                return (bool)GetValue(IsShowCPProperty);
            }
            set
            {
                SetValue(IsShowCPProperty, value);
                IsShowMaster = !value;
            }
        }
        private static void OnIsShowCPChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.IsShowCP = (bool)e.NewValue;
            }
        }
        #endregion

        #region ==IsShowTG===========
        public static readonly DependencyProperty IsShowTGProperty = DependencyProperty.Register("IsShowTG",
        typeof(bool), typeof(UIABPOS),
        new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsShowTGChanged));
        public bool IsShowTG
        {
            get
            {
                return (bool)GetValue(IsShowTGProperty);
            }
            set
            {
                SetValue(IsShowTGProperty, value);
                IsShowMaster = !value;
            }
        }
        private static void OnIsShowTGChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.IsShowTG = (bool)e.NewValue;
            }
        }
        #endregion
        #region ==IsABPCreated===========
        public static readonly DependencyProperty IsABPCreatedProperty = DependencyProperty.Register("IsABPCreated",
        typeof(bool), typeof(UIABPOS),
        new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsABPCreatedChanged));
        public bool IsABPCreated
        {
            get
            {
                return (bool)GetValue(IsABPCreatedProperty);
            }
            set
            {
                SetValue(IsABPCreatedProperty, value);
                IsShowMaster = !value;
            }
        }
        private static void OnIsABPCreatedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.IsABPCreated = (bool)e.NewValue;
            }
        }
        #endregion
        

        #region ==IsShowVV===========
        public static readonly DependencyProperty IsShowVVProperty = DependencyProperty.Register("IsShowVV",
        typeof(bool), typeof(UIABPOS),
        new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsShowVVChanged));
        public bool IsShowVV
        {
            get
            {
                return (bool)GetValue(IsShowVVProperty);
            }
            set
            {
                SetValue(IsShowVVProperty, value);
                IsShowMaster = !value;
            }
        }
        private static void OnIsShowVVChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.IsShowVV = (bool)e.NewValue;
            }
        }
        #endregion

        #region ==IsShowAB===========
        public static readonly DependencyProperty IsShowABProperty = DependencyProperty.Register("IsShowAB",
        typeof(bool), typeof(UIABPOS),
        new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsShowABChanged));
        public bool IsShowAB
        {
            get
            {
                return (bool)GetValue(IsShowABProperty);
            }
            set
            {
                SetValue(IsShowABProperty, value);
                IsShowMaster = !value;
            }
        }
        private static void OnIsShowABChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.IsShowAB = (bool)e.NewValue;
            }
        }
        #endregion

        #region ==MAKE2ORD===========
        public static readonly DependencyProperty MAKE2ORDProperty = DependencyProperty.Register("MAKE2ORD",
        typeof(bool), typeof(UIABPOS),
        new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnMAKE2ORDChanged));
        public bool MAKE2ORD
        {
            get
            {
                return (bool)GetValue(MAKE2ORDProperty);
            }
            set
            {
                SetValue(MAKE2ORDProperty, value);
                IsShowMaster = !value;
            }
        }
        private static void OnMAKE2ORDChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.MAKE2ORD = (bool)e.NewValue;
            }
        }
        #endregion 

        #region ==IsShowMaster===========
        public static readonly DependencyProperty IsShowMasterProperty = DependencyProperty.Register("IsShowMaster",
        typeof(bool), typeof(UIABPOS),
        new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsShowMasterChanged));
        public bool IsShowMaster
        {
            get
            {
                return (bool)GetValue(IsShowMasterProperty);
            }
            set
            {
                SetValue(IsShowMasterProperty, value);
            }
        }
        private static void OnIsShowMasterChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.IsShowMaster = (bool)e.NewValue;
            }
        }
        #endregion

        #region ==IsZutei===========
        public static readonly DependencyProperty IsZuteiProperty = DependencyProperty.Register("IsZutei",
        typeof(bool), typeof(UIABPOS),
        new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsZuteiChanged));
        public bool IsZutei
        {
            get
            {
                return (bool)GetValue(IsZuteiProperty);
            }
            set
            {
                SetValue(IsZuteiProperty, value);
            }
        }
        private static void OnIsZuteiChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.IsZutei = (bool)e.NewValue;
            }
        }
        #endregion

        #region ==NEUDATS===========
        public static readonly DependencyProperty NEUDATSProperty = DependencyProperty.Register("NEUDATS",
        typeof(string), typeof(UIABPOS),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnNEUDATSChanged));
        public string NEUDATS
        {
            get
            {
                return (string)GetValue(NEUDATSProperty);
            }
            set
            {
                SetValue(NEUDATSProperty, value);
            }
        }
        private static void OnNEUDATSChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.NEUDATS = (string)e.NewValue;
            }
        }
        #endregion

        #region ==NEUDATE===========
        public static readonly DependencyProperty NEUDATEProperty = DependencyProperty.Register("NEUDATE",
        typeof(string), typeof(UIABPOS),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnNEUDATEChanged));
        public string NEUDATE
        {
            get
            {
                return (string)GetValue(NEUDATEProperty);
            }
            set
            {
                SetValue(NEUDATEProperty, value);
            }
        }
        private static void OnNEUDATEChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.NEUDATE = (string)e.NewValue;
            }
        }
        #endregion

        #region ==dwWS===========
        public static readonly DependencyProperty dwWSProperty = DependencyProperty.Register("dwWS",
        typeof(DataRow), typeof(UIABPOS),
        new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OndwWSChanged));
        public DataRow dwWS
        {
            get
            {
                return (DataRow)GetValue(dwWSProperty);
            }
            set
            {
                SetValue(dwWSProperty, value);
                
            }
        }
        private static void OndwWSChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.dwWS = (DataRow)e.NewValue;
                src.OnWSChg((DataRow)e.NewValue);
            }
        }
        public virtual void OnWSChg(DataRow _dwWS)
        {
            TMV.dwWS = dwWS;
        }
        #endregion

        #region ==FLOW===========
        public static readonly DependencyProperty FLOWProperty = DependencyProperty.Register("FLOW",
        typeof(string), typeof(UIABPOS),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnFLOWChanged));
        public string FLOW
        {
            get
            {
                return (string)GetValue(FLOWProperty);
            }
            set
            {
                SetValue(FLOWProperty, value);
                OnFLOWChg(value);
            }
        }
        private static void OnFLOWChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.FLOW = (string)e.NewValue;
            }
        }
        public virtual void OnFLOWChg(string value)
        {
            if (dwMaster == null)
                return;
             
        }
        #endregion

        #region ==EXTPROD===========
        public static readonly DependencyProperty EXTPRODProperty = DependencyProperty.Register("EXTPROD",
        typeof(string), typeof(UIABPOS),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnEXTPRODChanged));
        public string EXTPROD
        {
            get
            {
                return (string)GetValue(EXTPRODProperty);
            }
            set
            {
                SetValue(EXTPRODProperty, value);
                OnEXTPRODChg(value);
            }
        }
        private static void OnEXTPRODChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.EXTPROD = (string)e.NewValue;
            }
        }
        public virtual void OnEXTPRODChg(string value)
        {
            if (dwMaster == null)
                return;

        }
        #endregion

        #region ==ABPSTKLG===========
        public static readonly DependencyProperty ABPSTKLGProperty = DependencyProperty.Register("ABPSTKLG",
        typeof(double), typeof(UIABPOS),
        new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnABPSTKLGChanged));
        public double ABPSTKLG
        {
            get
            {
                return (double)GetValue(ABPSTKLGProperty);
            }
            set
            {
                SetValue(ABPSTKLGProperty, value);
                OnABPSTKLGChg();
            }
        }
        private static void OnABPSTKLGChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.ABPSTKLG = (double)e.NewValue;
            }
        }
        public virtual void OnABPSTKLGChg()
        {
            if (dwMaster == null)
                return;

        }
        #endregion

        #region ==ABPSOLLMENGE5===========
        public static readonly DependencyProperty ABPSOLLMENGE5Property = DependencyProperty.Register("ABPSOLLMENGE5",
        typeof(double), typeof(UIABPOS),
        new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnABPSOLLMENGE5Changed));
        public double ABPSOLLMENGE5
        {
            get
            {
                return (double)GetValue(ABPSOLLMENGE5Property);
            }
            set
            {
                SetValue(ABPSOLLMENGE5Property, value);
                OnABPSOLLMENGE5Chg();
            }
        }
        private static void OnABPSOLLMENGE5Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.ABPSOLLMENGE5 = (double)e.NewValue;
            }
        }
        public virtual void OnABPSOLLMENGE5Chg()
        {
            if (dwMaster == null)
                return;

        }
        #endregion 

        #region ==ABPSOLLMENGE7===========
        public static readonly DependencyProperty ABPSOLLMENGE7Property = DependencyProperty.Register("ABPSOLLMENGE7",
        typeof(double), typeof(UIABPOS),
        new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnABPSOLLMENGE7Changed));
        public double ABPSOLLMENGE7
        {
            get
            {
                return (double)GetValue(ABPSOLLMENGE7Property);
            }
            set
            {
                SetValue(ABPSOLLMENGE7Property, value);
                OnABPSOLLMENGE7Chg();
            }
        }
        private static void OnABPSOLLMENGE7Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.ABPSOLLMENGE7 = (double)e.NewValue;
            }
        }
        public virtual void OnABPSOLLMENGE7Chg()
        {
            if (dwMaster == null)
                return;

        }
        #endregion
                
         
        #region ==VKDELDATE===========
        public static readonly DependencyProperty VKDELDATEProperty = DependencyProperty.Register("VKDELDATE",
            typeof(string), typeof(UIABPOS),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnVKDELDATEChanged));
        public string VKDELDATE
        {
            get
            {
                return (string)GetValue(VKDELDATEProperty);
            }
            set
            {
                SetValue(VKDELDATEProperty, value);
            }
        }
        private static void OnVKDELDATEChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.VKDELDATE = (string)e.NewValue;
            }
        }
        #endregion
        #region ==P01===========
        public static readonly DependencyProperty P01Property = DependencyProperty.Register("P01",
        typeof(string), typeof(UIABPOS),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnP01Changed));
        public string P01
        {
            get
            {
                return (string)GetValue(P01Property);
            }
            set
            {
                SetValue(P01Property, value); 
            }
        }
        private static void OnP01Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIABPOS;
            if (src != null)
            {
                src.P01 = (string)e.NewValue;
            }
        }
        #endregion

    }
}
